package com.face.gaoml.netlibrary.data.exception;


import com.face.gaoml.netlibrary.widget.MsgAlert;

import java.io.IOException;

import retrofit2.adapter.rxjava.HttpException;

/**
 * Created by gml on 16/12/9.
 */

public class ApiErrorHelper {

    public static void handleCommonError( Throwable e) {
        if (e instanceof HttpException) {
            new MsgAlert().show("服务暂不可用");
        } else if (e instanceof IOException) {
            new MsgAlert().show("连接失败，请检查网络！");
        } else if (e instanceof ApiException) {
            //ApiException处理
            new MsgAlert().show(((ApiException)e).getMessage());
        } else {
            new MsgAlert().show("未知错误");
        }
    }
}
